<%@ page import="java.util.HashMap,common.CommonUtil,java.util.*,common.*" contentType="text/html; charset=utf-8" %>

<%
UserSession userSession = (UserSession)session.getAttribute("user"); 

//String login_id = null;
String user_id = null;

if(userSession!= null){
	//login_id = userSession.getLogin_id();
	user_id = userSession.getUser_id();
}

HashMap listMap=(HashMap)request.getAttribute("list_map");

HashMap map  = null;
ArrayList list=null;


if (listMap!=null){
    list=(ArrayList)listMap.get("mainContent");
}

String rater_id = null;
String login_id = null;
String login_pw = null;
String login_name = null;

String email = null;
String tel_no = null;
String addr = null;

String bank_nm = null;
String bank_no = null;
String photo_nm = null;
String photo_id = null;
String state = null;

if(list != null){
	if(list.size() > 0){
		rater_id = (String)((HashMap)list.get(0)).get("rater_id");		
		login_id = Crypto.DecodeBySType((String)((HashMap)list.get(0)).get("login_id"));
		login_pw = Crypto.DecodeBySType((String)((HashMap)list.get(0)).get("login_pw"));
		login_name = (String)((HashMap)list.get(0)).get("login_name");
		
		email = CommonUtil.nvl((String)((HashMap)list.get(0)).get("email"));
		tel_no = CommonUtil.nvl((String)((HashMap)list.get(0)).get("tel_no"));
		addr = CommonUtil.nvl((String)((HashMap)list.get(0)).get("addr"));
		
		bank_nm = CommonUtil.nvl((String)((HashMap)list.get(0)).get("bank_nm"));
		bank_no = CommonUtil.nvl((String)((HashMap)list.get(0)).get("bank_no"));
		photo_nm = CommonUtil.nvl((String)((HashMap)list.get(0)).get("photo_nm"));
		photo_id = CommonUtil.nvl((String)((HashMap)list.get(0)).get("photo_id"));
		state = CommonUtil.nvl((String)((HashMap)list.get(0)).get("state"));
		
	}
}


%>
<jsp:include page="/jsp/common/header.jsp"></jsp:include>

<script>

//xml 요청
function getXMLHTTPRequest() {
try {
  req = new XMLHttpRequest();
} catch(err1) {
  try {
  req = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (err2) {
    try {
    req = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (err3) {
      req = false;
    } 
  } 
}
return req;
}


function get_login_chk_request(id){
  
  var http = getXMLHTTPRequest();
  var myurl = '/speaking.pb?gubun=admin&cmd=id_chk&id='+id;
  myRand = parseInt(Math.random()*999999999999999);
  var modurl = myurl+"&rand="+myRand;  
  http.open("get", modurl, false);
  //http.onreadystatechange = useHttpResponse;
  http.send(null);
  if (http.readyState == 4) {
    return trim(http.responseText);
  }else{
   return "";
  }
} 	

function trim(str){
	str = str.replace(/(^\s*)|(\s*$)/g,"");
	return str;
}

function get_login_chk(){
	var id = document.mainform.login_id.value;
	if(id == ''){
		alert('id 를 입력해주세요');
		document.mainform.login_id.focus();
		return;
	}
	var id_chk_cnt = get_login_chk_request(id);
	
	if(id_chk_cnt==0){
		document.mainform.id_chk.value='Y';
		alert('사용하실 수 있는 id 입니다');
	}else{
		document.mainform.id_chk.value='N';
		alert('사용하실 수 없는 id 입니다');
		document.mainform.login_id.focus();
		document.mainform.login_id.value='';
	}
}

function go_input(){
	var frm = document.mainform;	
	
	
	if(frm.login_name.value==''){
		alert('이름을 입력 해주세요');
		frm.login_name.focus();
		return;
	}
	if(frm.login_pw.value==''){
		alert('비밀번호 입력 해주세요');
		frm.login_pw.focus();
		return;
	}
	
	//frm.cmd.value='rater_insert';
	frm.action = '/speaking.pb?cmd=rater_modify';
	frm.target= 'hidden_frm';              
	frm.submit();	
}

function go_rater(){
	var frm = document.mainform;	
	//frm.cmd.value='rater_main';
	frm.action = '/speaking.pb?cmd=rater_main';
	frm.target= '_self';              
	frm.submit();	
}
</script>

<jsp:include page="/jsp/common/top.jsp"></jsp:include>
<jsp:include page="/jsp/common/submenu.jsp"><jsp:param name="submenu_id" value="rater_main" /><jsp:param name="submenu_idx" value="1" /></jsp:include>

<form name="mainform"  method="post" action = "/speaking.pb" enctype= "multipart/form-data">
	<div id="bodyContainer">
        <div id="contents">
          <jsp:include page="/jsp/common/submenu_list.jsp"><jsp:param name="submenu_id" value="rater_main" /><jsp:param name="submenu_idx" value="3" /></jsp:include>
          
          
          <div class="boxContainer">
            <dl title="Rater 수정">
              <dt>Rater 수정</dt>
            </dl>
            <table class="setupTb">
            
              <tr>
                <th>ID</th>
                <td><input type="text" name="login_id" id="login_id" style="width:100px" value="<%=login_id %>" readonly/> </td>
              </tr>
              <tr>
                <th>이름</th>
                <td><input type="text" name="login_name" id="login_name" style="width:100px" value="<%=login_name %>"/></td>
              </tr>
              <tr>
                <th>비밀번호</th>
                <td><input type="password" name="login_pw" id="login_pw" style="width:100px" value="<%=login_pw %>"/></td>
              </tr>
              <tr>
                <th>주소</th>
                <td><input type="text" name="addr" id="addr" style="width:100px" value="<%= addr%>"/></td>
              </tr>
              
              <tr>
                <th>email</th>
                <td><input type="text" name="email" id="email" style="width:100px" value="<%=email %>"/></td>
              </tr>
              <tr>
                <th>연락처</th>
                <td><input type="text" name="tel_no" id="tel_no" style="width:100px" value="<%= tel_no%>"/></td>
              </tr>
              <tr>
                <th>은행명</th>
                <td><input type="text" name="bank_nm" id="bank_nm" style="width:200px" value="<%= bank_nm%>"/></td>
              </tr>
              <tr>
                <th>계좌번호</th>
                <td><input type="text" name="bank_no" id="bank_no" style="width:200px" value="<%= bank_no%>"/></td>
              </tr>
              <tr>
                <th>사진</th>
                <td>
                  <input type="file" name="attachFile" id="attachFile" style="width:200px"/>
                <%if(!photo_id.equals("")){ %>
                <br>                
                <img src="/speaking.pb?cmd=download2&file_id=<%=photo_id %>&file_name=<%=photo_id %>&file_folder=rater" />
                <%} %>
                </td>
              </tr>
              <tr>
                <th>상태</th>
                <td><input type="radio" name="state" id="state" value="1" <%=(state.equals("1"))?"checked":"" %> />
                  <span class="boldText">활성</span>
                  <input type="radio" name="state" id="state" value="2" <%=(state.equals("2"))?"checked":"" %>/>
                  <span class="boldText">비활성</span></td>
              </tr>
                        
            </table>
            <p><a href="#" onclick="go_input()"><img src="img/btn_regist.gif" alt="등록" width="49" height="20" /></a> <a href="#" onclick="go_rater()"><img src="img/btn_list.gif" alt="목록" width="49" height="20" /></a> </p>
            
          </div>
          
        </div>
      </div>


<input type="hidden" name="cmd" value="">
<input type="hidden" name="user_id" value="<%=user_id %>">
<input type="hidden" name="rater_id" value="<%=rater_id %>">

<input type="hidden" name="photo_nm" value="<%=photo_nm %>">
<input type="hidden" name="photo_id" value="<%=photo_id %>">
<input type="hidden" name="id_chk" value="N">

</form>

<iframe name='hidden_frm'  width='0' height='0' SCROLLING='AUTO' frameborder='0'></iframe>
<jsp:include page="/jsp/common/footer.jsp"></jsp:include>
<jsp:include page="/jsp/common/bottom.jsp"></jsp:include>
